package com.ty.user.starter.shiro.filter;

import com.ty.user.starter.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.web.filter.authc.AuthenticationFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

@Slf4j
public class UserMgtAuthenticationFilter extends AuthenticationFilter {

    @Override
    protected boolean onAccessDenied(ServletRequest request, ServletResponse response) {
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        log.error("请求地址未登录: {}", httpServletRequest.getRequestURI());
        ResponseUtil.writer(response, 401, "未登录", null);
        return false;
    }

}
